package com.huiquan.foundation.service;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huiquan.analysis.domain.User;
import com.huiquan.foundation.dao.TabHelpDao;
import com.huiquan.foundation.domain.TabHelp;
import com.huiquan.framework.base.BaseService;

@Service("tabHelpService")
public class TabHelpService extends BaseService {
	@Autowired
	private TabHelpDao tabHelpDao;

	public Map<String, Object> list(String tabId,User user) {
		if (StringUtils.isNotBlank(tabId)) {
			TabHelp tab = tabHelpDao.retrieveBytabId(tabId);
			if(tab == null){
				tabHelpDao.insert(tabId,user);
				tab = tabHelpDao.retrieveBytabId(tabId);
			}
			Map<String, Object> rtnMap = new HashMap<>();
			rtnMap.put("operation", tab.getOperationHelp());
			rtnMap.put("remark", tab.getRemark());
			return rtnMap;
		} else {
			return null;
		}
	}

	public void change(String tabId, String newRemark, User user) {
		tabHelpDao.updateRemark(tabId, newRemark, user);
	}
}
